home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 182_01 / xpnd.c < prev   
C/C++ Source or Header  |  1990-07-30  |  2KB  |  68 lines

  1. /*
  2.     xpnd.c    - expand standard input by specified horizontal
  3.         and vertical expansion factors.  Write the results
  4.         to standard output.
  5.     
  6.         In general, this is a pretty worthless program, but if you
  7.         process an ascii picture file such as the peanuts characters
  8.         that are so popular, or even a nude, the result can be pretty
  9.                 amazing. A friend of mine and I xpnd'ed a one page nude to be
  10.         eleven feet tall! Enjoy.
  11.  
  12.         Marty Chamberlain,    1/7/86
  13.         Hdwr: AT&T 3B1
  14.         Opsy: UNIX Version 5, AT&T release v3.0
  15.  
  16. */
  17. #include <stdio.h>
  18. #include <ctype.h>
  19.  
  20. #define maxline 5000 /* maximum line size (5000 is a bit excessive!) */
  21.  
  22. main(argc,argv)
  23.   int argc;
  24.   char *argv[];
  25. {
  26.     int horzxpnd,vertxpnd;
  27.     int len;
  28.     int i,j,k;
  29.     char line[maxline];
  30.  
  31.     if(argc!=3)
  32.       fprintf(stderr,"xpnd...M. Chamberlain 1986:\nUsage: \
  33. xpnd horizontal vertical\n\n\
  34. where horizontal is horizontal expansion factor and\n\
  35.       vertical is vertical expansion factor\n");
  36.     else
  37.     if((atoi(argv[1])<=0) || (atoi(argv[2])<=0))
  38.       fprintf(stderr,"xpnd...M. Chamberlain 1986:\n\
  39. Arguments must be positive integers\n");
  40.     else
  41.       {
  42.       horzxpnd=atoi(argv[1]);
  43.       vertxpnd=atoi(argv[2]);
  44.       while ((len=getline(line,maxline))>0)
  45.         for (i=0;i<=vertxpnd-1;++i) {
  46.           for (j=0;j<=len-2;++j)
  47.             for (k=0;k<=horzxpnd-1;++k)
  48.               putchar(line[j]);
  49.           putchar('\n');
  50.         }
  51.       }
  52. }
  53.  
  54. getline(s,lim) /* get a line of input from standard input */
  55. char s[];
  56. int lim;
  57. {
  58.     int c,i;
  59.     for (i=0;i<lim-1 && (c=getchar())!=EOF && c!='\n';++i)
  60.       s[i]=c;
  61.     if (c=='\n') {
  62.       s[i]=c;
  63.       ++i;
  64.     }
  65.     s[i]='\0';
  66.     return(i);
  67. }
  68.